unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ZConnection, DB, ZAbstractRODataset,
  ZAbstractDataset, ZStoredProcedure, ZDataset;

type
  TForm1 = class(TForm)
    Button_DarLance: TButton;
    LabeledEdit_Leilao1: TLabeledEdit;
    LabeledEdit_Usuario1: TLabeledEdit;
    ACDM: TZConnection;
    ZROQ: TZReadOnlyQuery;
    Button_ZerarLeilao: TButton;
    LabeledEdit_Leilao2: TLabeledEdit;
    procedure Button_DarLanceClick(Sender: TObject);
    procedure Button_ZerarLeilaoClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button_DarLanceClick(Sender: TObject);
begin
  with ZROQ do
    try
      SQL.Text := Format('CALL DARLANCE(%S,%S)',[LabeledEdit_Usuario1.Text,LabeledEdit_Leilao1.Text]);
      ExecSQL;
    finally
      Close;
    end;
end;

procedure TForm1.Button_ZerarLeilaoClick(Sender: TObject);
begin
  with ZROQ do
    try
      SQL.Text := Format('DELETE FROM LANCE WHERE BI_LEILAO_ID = %S',[LabeledEdit_Leilao2.Text]);
      ExecSQL;
      SQL.Text := Format('UPDATE LEILAO SET DT_FIM = NULL, DT_DISPONIBILIZACAO = DATE_ADD(NOW(),INTERVAL +1 MINUTE), DT_INICIO = DATE_ADD(NOW(),INTERVAL +2 MINUTE) WHERE BI_LEILAO_ID = %S',[LabeledEdit_Leilao2.Text]);
      ExecSQL;
    finally
      Close;
    end;
end;

end.
